package com.chenfan.ccp.common.listener;

import com.google.common.eventbus.EventBus;
import org.springframework.beans.factory.InitializingBean;

public abstract class AbstractEventListener implements InitializingBean {
    private static final EventBus EVENT = new EventBus();

    public abstract Object getListener();

    @Override
    public void afterPropertiesSet() throws Exception {
        Object listener = getListener();
        if (listener != null) {
            EVENT.register(listener);
        }
    }

    public void sendEvent(Object obj) {
        EVENT.post(obj);
    }
}
